import request from '@/router/axios';
/**
 * 角色列表数据
 *
 */
export const getList = (current, size, params) => {
  return request({
    url: '/application/role/page',
    method: 'POST',
    params: {
      ...params,
      current,
      size,
    }
  })
}

/**
 * 添加角色
 * @param row
 */
export const add = (row) => {
  return request({
    url: '/application/role/add',
    method: 'post',
    data: row
  })
}

/**
 * 父级角色
 * @param id
 */
export const parent = (id) => {
  return request({
    url: '/application/role/parent',
    method: 'get'
  })
}

/**
 * 更新角色
 * @param row
 */
export const update = (row) => {
  return request({
    url: '/application/role/update',
    method: 'post',
    data: row
  })
}

/**
 * 删除角色
 * @param row
 */
export const remove = (row) => {
  return request({
    url: '/application/role/remove',
    method: 'post',
    data: row
  })
}

/**
 * 全部资源树
 */
export const grantResource = () => {
  return request({
    url: '/application/resource/grantResource',
    method: 'get'
  })
}

/**
 * 获取已配置的角色资源
 * @param roleId
 */
export const roleResource = (roleId) => {
  return request({
    url: '/application/role/roleResource',
    method: 'get',
    params: {
      roleId,
    }
  })
}

/**
 * 配置角色权限
 * @param roleId
 * @param menuIds
 */
export const grant = (roleId, menuIds) => {
  return request({
    url: '/application/role/grant',
    method: 'post',
    data: {
      "roleId": roleId,
      "menuIds": menuIds
    }
  })
}